package com.hqyj.ssm_project.service;

import com.hqyj.ssm_project.mapper.ApplicationMapper;
import com.hqyj.ssm_project.mapper.ApproveMapper;
import com.hqyj.ssm_project.mapper.DetailsMapper;
import com.hqyj.ssm_project.pojo.Application;
import com.hqyj.ssm_project.pojo.Approve;
import com.hqyj.ssm_project.pojo.Details;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ApplicationServiceImp implements ApplicationService {
    @Autowired
    private ApplicationMapper applicationMapper;
    @Autowired
    private DetailsMapper detailsMapper;
    @Autowired
    private ApproveMapper approveMapper;

    @Override
    public void insert(Application application) {
        applicationMapper.insertNoPrimaryKey(application);
    }

    @Override
    public void insertDetails(Details details) {
        detailsMapper.insertSelective(details);
    }

    @Override
    public void createApprove(Approve approve) {
        approveMapper.insertSelectiveReturnId(approve);
    }

    @Override
    public List<Application> selectByUserId(Integer id) {
        return applicationMapper.selectByUserId(id);
    }

    @Override
    public Application selectAppdetailById(Integer applicationId) {
        return applicationMapper.selectAppdetailById(applicationId);
    }

    @Override
    public int updateCommitTime(Application application) {
        return applicationMapper.updateCommitTime(application);
    }

    @Override
    public List<Application> selectListToApproveByApproveUserId(Integer userId) {
        return applicationMapper.selectListToApproveByApproveUserId(userId);
    }

    @Override
    public void updateStatus(Details details) {
        detailsMapper.updateStatus(details);
    }

    @Override
    public Approve selectApproveByapproveId(Integer approveId) {
        return approveMapper.selectApproveByapproveId(approveId);
    }

    @Override
    public void rejectApplication(Integer approveId) {
        detailsMapper.rejectApplication(approveId);
    }

    @Override
    public void approveApplication(Approve approve) {
        approveMapper.updateByPrimaryKeySelective(approve);
    }

    @Override
    public void updateStatusByApproveId(Details details) {
        detailsMapper.updateStatusByApproveId(details);
    }


}
